package match_data

import (
	"longmen/server/internal/services/nami/services/sports/basketball/bbcache"
	"longmen/server/internal/services/nami/services/sports/football/fbcache"
	"strconv"
)

func GetIndexData(roomId string) (historyMsg []string) {
	//嘗試獲取指數資訊
	if indexMsg, has := indexHistory(roomId); has {
		historyMsg = append(historyMsg, indexMsg)
	}
	return historyMsg
}

func indexHistory(roomId string) (string, bool) {
	matchId, err := strconv.Atoi(roomId)
	if err != nil {
		return "", false
	}
	var cache string

	cache = bbcache.NewOddsCache().GetOddsCache(matchId)
	if len(cache) > 0 {
		return cache, true
	}
	cache = fbcache.NewOddsRedis().GetOddsCache(matchId)
	if len(cache) > 0 {
		return cache, true
	}
	return "", false
}
